In Elixir, computation is viewed as a series of foundational transformations. Data is immutable, and the = operator is not for assignment, but for pattern matching.
1. The Match Operator
Matching allows you to bind values to patterns. If the structure of the left side doesn't match the right, the transformation fails. Elixir uses specialized operators for data flow: Arithmetic (+, -, *, /), Comparison (===, !==, >=), and Join (<> for strings, ++ for lists).
2. The 'with' Expression
The with expression orchestrates multi-step transformations where success is conditional. It allows chaining matches using <-. Unlike the match operator =, if a match in <- fails, the expression returns the non-matching value instead of raising an error.
3. Scoping and Syntax
Under the hood, with is treated as a macro or function call. Variables bound within it do not leak into the outer scope. Syntax like mean = with count = ..., do: sum/count is the expression-based way to calculate derived values.
$$\text{mean} = \frac{\sum_{i=1}^{n} x_i}{n}$$